home *** CD-ROM | disk | FTP | other *** search
/ C# & Game Programming - A…er's Guide (2nd Edition) / Buono 2nd Ed.iso / Chapter2 / 2.3 / 2.3.cs next >
Encoding:
Text File  |  2004-08-31  |  681 b   |  26 lines

  1. /* Using the if statement with numerical data. */
  2. using System;
  3.  
  4. namespace Chapter2 {
  5.     class Class1 {
  6.         static void Main() {
  7.             int iAnswer;
  8.  
  9.             // Step 1                                           
  10.             Console.Write("1 + 1 =  ");
  11.  
  12.             // Step 2
  13.             iAnswer = int.Parse(Console.ReadLine());
  14.  
  15.             // Step 3 û numbers do not require quotes
  16.             if (iAnswer == 2)    
  17.                 Console.WriteLine("\n That is correct!\n");
  18.  
  19.             // Step 4
  20.             if (iAnswer != 2)  
  21.                 Console.WriteLine("\n Wrong!!!\n");
  22.         }
  23.     }
  24. }                                        
  25.  
  26.